/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package rentcalculator.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;

/**
 *
 * @author K.E.Y
 */

@Entity
public class Lodgement {
    @Id
    @GeneratedValue(strategy = IDENTITY)
    private long id;
    private Date start;

    public List<Absence> getAbsences() {
        return absences;
    }

    public void setAbsences(List<Absence> absences) {
        this.absences = absences;
    }
    private Date end;
    
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name="person_id")
    private Person person;
    
    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name="facility_id")
    private Facility facility;
    
    @OneToMany(mappedBy="lodgement", fetch = FetchType.EAGER)
    private List<Absence> absences;

    
    public Lodgement(){
        this.absences = new ArrayList<>();
    }
    
    public Lodgement( Date start, Person person, Facility facility) {
        this.start = start;
        this.person = person;
        this.facility = facility;
        this.absences = new ArrayList<>();
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public Date getStart() {
        return start;
    }

    public void setStart(Date start) {
        this.start = start;
    }

    public Date getEnd() {
        return end;
    }

    public void setEnd(Date end) {
        this.end = end;
    }

    public Person getPerson() {
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }

    public Facility getFacility() {
        return facility;
    }

    public void setFacility(Facility facility) {
        this.facility = facility;
    }
}
